package com.dongdongshop.service.imp;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbBrandMapper;
import com.dongdongshop.mapper.TbTypeTemplateMapper;
import com.dongdongshop.pojo.TbBrand;
import com.dongdongshop.pojo.TbTypeTemplate;
import com.dongdongshop.service.BrandService;
import com.dongdongshop.util.PageBean;

import javax.annotation.Resource;
import java.util.List;

@Service
@org.springframework.stereotype.Service
public class BrandServiceImpl implements BrandService {
    @Resource
    private TbBrandMapper tbBrandMapper;
    @Resource
    private TbTypeTemplateMapper tbTypeTemplate;

    @Override
    public PageBean<TbBrand> getinfo(Integer number,Integer pageSize) {
        PageBean<TbBrand> b = new PageBean<>();
        b.setPageNum(number);
        b.setPageSize(pageSize);
        List<TbBrand> list = tbBrandMapper.getinfo(b);
        b.setResult(list);
        List<TbBrand> slist = tbBrandMapper.selectByExample(null);
        b.setTotal(slist.size());
        return b;
    }

    @Override
    public Integer addinfo(TbBrand tbBrand) {
        return tbBrandMapper.insertSelective(tbBrand);
    }

    @Override
    public Integer deleteAll(Integer[] ids) {
        return tbBrandMapper.deleteAll(ids);
    }

    @Override
    public TbBrand getUpdate(Long id) {
        return tbBrandMapper.selectByPrimaryKey(id);
    }

    @Override
    public Integer updateinfo(TbBrand tbBrand) {
        return tbBrandMapper.updateByPrimaryKeySelective(tbBrand);
    }

    @Override
    public List<TbBrand> getAll() {
        return tbBrandMapper.selectByExample(null);
    }

    @Override
    public TbBrand getById(Long brandId) {
        return tbBrandMapper.selectByPrimaryKey(brandId);
    }
}
